﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ppt = Microsoft.Office.Interop.PowerPoint;
using System.Drawing;

namespace ObjectModel.PowerPoint
{
    /// <summary>
    /// A basic container for a PowerPoint slide object that holds ID and Name information
    /// after the slide is not longer accesible (e.g. after having been deleted).
    /// </summary>
    public struct SlideInfo
    {
        public readonly int Id;
        public readonly string Name;
        public readonly Ppt.Slide Slide;
        public readonly ShapeInfo[] Shapes;

        public SlideInfo(Ppt.Slide slide)
        {
            Slide = slide;
            Id = slide.SlideID;
            Name = slide.Name;

            Shapes = (from Ppt.Shape s in slide.Shapes
                      select new ShapeInfo(s)).ToArray();
        }

        public override bool Equals(object obj)
        {
            if (!(obj is SlideInfo)) return false;

            return Equals((SlideInfo)obj);
        }

        public bool Equals(SlideInfo s)
        {
            return Id == s.Id;
        }

        public static bool operator ==(SlideInfo s1, SlideInfo s2)
        {
            return s1.Equals(s2);
        }

        public static bool operator !=(SlideInfo s1, SlideInfo s2)
        {
            return !(s1 == s2);
        }

        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }
    }
}
